(function(){
    var _this=this;
    return {
        init:function(){
            var appId="wxbd4a688a033462be";
            var weixinUserToken=_this.params.weixinUserToken;
            if(!weixinUserToken){
                weixinUserToken=$.cookie('weixinUserToken');
            }else{
                $.cookie("weixinUserToken",weixinUserToken,{path:"/" ,expires:365});
            }
            if(weixinUserToken==null){
                var url=window.location.protocol+"//"+window.location.host+":"+(window.location.port?window.location.port:"80")+window.api+"weixin/login?appId="+appId;
                var local=window.location.href;
                local=encodeURIComponent(local);
                 window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+url+"&response_type=code&scope=snsapi_userinfo&state="+local+"#wechat_redirect"
                return;
            }
            ajaxGet({
                url:"weixin/selfUser",
                success:function(data){
                    console.log(data);
                    _this.data.name=data.data.name;
                }
            })
        },
        data:{
            name:"微信名称"
        },
        before:function(data){
            return data;
        },
        after:function(){

        }
    }

})